from fractions import Fraction  

def calculate_payout_ratio(x, profit_margin=0.05):  
    """  
    Calculate the payout ratio A:B based on the probability of A winning (x) and a profit margin.  
      
    :param x: Probability of A winning (between 0 and 1)  
    :param profit_margin: The profit margin the house wishes to maintain (default is 5% or 0.05)  
    :return: The payout ratio A:B as a tuple (A_payout, B_payout)  
    """  
    if x < 0 or x > 1:  
        raise ValueError("Probability x must be between 0 and 1.")  
      
    # Calculate the expected payout rate after profit margin  
    expected_payout_rate = 1 - profit_margin  
      
    # Calculate the payout multiplier for A (the favorite)  
    A_payout = expected_payout_rate / x  
      
    # Since B is the underdog, its payout is typically much higher  
    # We calculate this based on the fact that the sum of probabilities for A and B should be 1  
    # (assuming no draw is possible) and the payouts should reflect this  
    B_payout = A_payout * (1 - x) / x  
      
    return A_payout, B_payout  
  
# Example usage:  
x = 0.99  # Probability of A winning  
A_payout, B_payout = calculate_payout_ratio(x)  
print(f"Payout ratio A:B is {A_payout:.5f}:{B_payout:.5f}")

decimal_number = A_payout/B_payout 
fraction = Fraction(decimal_number).limit_denominator(100)
print(fraction)